Review and analyze last two pull requests#70
Merged
MarcosBrendonDePaula merged 1 commit intomainfrom Feb 27, 2026
Merged
Conversation
- onAction cancellation no longer emits ERROR to client (info leak)
- setState skips emit/hooks when values are unchanged (parity with proxy)
- Silent catch {} replaced with console.error in onStateChange, onRoomJoin, onRoomLeave
- Singleton broadcast now includes userId and room metadata
- Add onClientJoin/onClientLeave lifecycle hooks for singletons
- Singleton onDisconnect only fires when last client leaves
- New hooks added to BLOCKED_ACTIONS for security
- 19 regression tests covering all fixed bugs
https://claude.ai/code/session_01JEtihEZe9cThDAadXAp3Rp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 6 bugs identified during the code review of PR #68 (LiveComponent DX Enhancements) and PR #69 (Bugfix followup). All fixes include regression tests that first fail to prove the bug exists, then pass after the fix is applied.
Bugs Fixed
1.
onActioncancellation leaks internal info to client (HIGH)Before: When
onAction()returnsfalse, the error"cancelled by onAction hook"was emitted as anERRORmessage to the client, revealing server-side rate-limiting/guard logic.After: Cancelled actions no longer emit
ERRORto the client. The thrown error uses a generic"was cancelled"message. IfonActionitself throws, the client receives"failed pre-validation"without leaking hook details.2.
setStateemitsSTATE_DELTAeven when values are unchanged (MEDIUM)Before:
setState({ count: 0 })on a component withcount: 0would emit aSTATE_DELTAand fireonStateChange, causing unnecessary network traffic. The proxysethandler already had this check, butsetStatedid not.After:
setStatenow filters to only actually-changed keys before emitting. If nothing changed, it's a no-op. Consistent with proxy behavior.3. Silent
catch {}swallows lifecycle hook errors (MEDIUM)Before: Errors in
onStateChange,onRoomJoin, andonRoomLeavewere caught with emptycatch {}blocks — zero feedback when developer code fails.After: All three hooks now log errors via
console.error.4. Singleton broadcast missing
userIdandroommetadata (MEDIUM)Before: The singleton emit override in
ComponentRegistrycreatedLiveMessageobjects withoutuserIdorroomfields, breaking client-side logic that depends on these fields.After: The override now includes
userId: component.userIdandroom: component.room, matching the normal emit path.5. New
onClientJoin/onClientLeavelifecycle hooks for singletons (HIGH)Before: Singleton
onConnectonly fired for the first client.onDisconnectfired for every client disconnect, even when others were still connected. No way to track per-connection events.After:
onClientJoin(connectionId, connectionCount)fires for every new client joining a singleton (including the first)onClientLeave(connectionId, connectionCount)fires for every client leavingonDisconnectnow only fires when the last client disconnects (semantically correct)BLOCKED_ACTIONSfor security6.
onActionthrowing (not returning false) not properly handledBefore: If
onActionthrew an exception (as opposed to returningfalse), the raw error message was sent to the client via the genericERRORemit.After:
onActionexceptions are caught separately and the client receives a sanitized"failed pre-validation"message instead of the raw error.Files Changed
core/types/types.tscore/server/live/ComponentRegistry.tstests/unit/core/live-component-bugfixes.test.tstests/unit/core/live-component-dx.test.tsTest Plan
live-component-bugfixes.test.ts